package com.spdzen.support.result;

import java.io.Serializable;

public class BizResultCode implements ResultCode, Serializable {
	private static final long serialVersionUID = 6519903593412131379L;
	
	/**
	 * 代码
	 */
	private String code;

	/**
	 * 提示消息，该消息会返回给客户端。
	 */
	private String message;

	/**
	 * 描述信息，该描述不会返回给客户端。
	 */
	private String description;
	
	public static BizResultCode error() {
		BizResultCode rc = new BizResultCode();
		rc.setCode(BaseResultCode.getErrorCode());
		rc.setMessage("");
		rc.setDescription("");
		return rc;
	}
	
	public static BizResultCode error(String message) {
		BizResultCode rc = new BizResultCode();
		rc.setCode(BaseResultCode.getErrorCode());
		rc.setMessage(message);
		rc.setDescription(message);
		return rc;
	}
	
	public static BizResultCode success(String message) {
		BizResultCode rc = new BizResultCode();
		rc.setCode(BaseResultCode.getSuccessCode());
		rc.setMessage(message);
		rc.setDescription(message);
		return rc;
	}
	
	public static BizResultCode success() {
		BizResultCode rc = new BizResultCode();
		rc.setCode(BaseResultCode.getSuccessCode());
		rc.setMessage("");
		rc.setDescription("");
		return rc;
	}
	
	public BizResultCode() {
	}
	
	public BizResultCode(String code, String message) {
		this.code = code;
		this.message = message;
		this.description = message;
	}
	
	public BizResultCode(String code, String message, String description) {
		this.code = code;
		this.message = message;
		this.description = description;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("{code=").append(this.code).append(", ");
		sb.append("message=").append(this.message).append(", ");
		sb.append("description=").append(this.description).append("}");
		return sb.toString();
	}
}
